package com.iwhalecloud.bss.kite.cucc.dataservice.mapper.batch;

import com.iwhalecloud.bss.kite.cucc.client.dto.batch.KiteBatchAcceptDetail;
import com.iwhalecloud.bss.kite.cucc.client.dto.batch.KiteBatchAcceptDetailDTO;
import com.ztesoft.bss.base.extmapper.BaseMapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;
import java.util.Map;

/**
 * @author Prox
 */
public interface KiteBatchAcceptDetailMapper extends BaseMapper<KiteBatchAcceptDetail> {

    /**
     * 根据校验状态和数量查询
     *
     * @param importType 导入类型
     * @param checkStatus 校验状态
     * @param num 查询行数
     * @return
     */
    List<KiteBatchAcceptDetailDTO> listKiteBatchAcceptDetailByBatchId(@Param("batchId") String batchId, @Param("importType") String importType,
        @Param("checkStatus") String checkStatus, @Param("num") Integer num);

    /**
     * 根据校验状态和数量查询
     *
     * @param importType 导入类型
     * @param checkStatus 校验状态
     * @param num 查询行数
     * @return
     */
    List<KiteBatchAcceptDetail> listKiteBatchAcceptDetail(@Param("importType") String importType,
                                                          @Param("checkStatus") String checkStatus, @Param("num") Integer num);

    /**
     * 查询未处理明细
     *
     * @param importType 导入类型
     * @param batchId 校验状态
     * @return
     */
    List<KiteBatchAcceptDetail> listNotDealDetail(@Param("batchId") String batchId, @Param("importType") String importType);

    List<KiteBatchAcceptDetail> queryKiteBatchAcceptDetail(Map<String, Object> paramMap);

    /**
     * 更新转单处理结果
     *
     * @param statusCd
     * @param detailId
     * @param dealResult
     */
    void updateKiteBatchAcceptDetailStatus(@Param("statusCd") String statusCd, @Param("detailId") Long detailId,
        @Param("dealResult") String dealResult, @Param("batchId") Long batchId);

    /**
     * 更新校验结果
     * @param checkStatus
     * @param detailId
     * @param checkResult
     */
    void updateKiteBatchAcceptDetailCheckStatus(@Param("checkStatus") String checkStatus, @Param("detailId") Long detailId,
        @Param("checkResult") String checkResult, @Param("batchId") Long batchId);

    /**
     * 导出结果查询
     * @param batchId
     * @return
     */
    List<Map<String, Object>> queryKiteGroupBatchLogForList(@Param("batchId") String batchId);

    /**
     * 查询提交的明细
     * @param importTypes
     * @param batchStatusCd
     * @param checkStatus
     * @param statusCd
     * @return
     */
    List<String> listCommitBatchId(@Param("importTypes") List<String> importTypes,
        @Param("batchStatusCd") String batchStatusCd, @Param("checkStatus") String checkStatus,
        @Param("statusCd") String statusCd);

    void updateRandom(@Param("randomNum") String randomNum, @Param("batchId") String batchId, @Param("num") Integer num, @Param("checkStatus") String checkStatus);

    List<KiteBatchAcceptDetailDTO> listExecuteDetails(@Param("batchId") String batchId, @Param("randomNum") String randomNum);

    List<KiteBatchAcceptDetailDTO> listExecuteDetailsByStatus(@Param("importType") String importType,
        @Param("checkStatus") String checkStatus, @Param("num") Integer num);

    Integer listCommitBatchDetailCount(@Param("batchId") Long batchId, @Param("checkStatus") String checkStatus,
        @Param("statusCd") String statusCd);

    int deleteDetailByBatchId(@Param("detailIds") List<String> detailIds, @Param("batchId") String batchId);

    int recommitUpdate(@Param("detailIds") List<Long> detailIds, @Param("batchId") String batchId);

    int clearOfferInstId(@Param("batchId") Long batchId, @Param("detailId") Long detailId);

    void updateKiteBatchAcceptDetailStatusAndOrderId(@Param("kiteBatchAcceptDetailList") List<KiteBatchAcceptDetail> kiteBatchAcceptDetailList);

    void updateRandomNumByDetail(@Param("randomNum") String randomNum,
        @Param("kiteBatchAcceptDetailList") List<KiteBatchAcceptDetail> kiteBatchAcceptDetailList,
        @Param("num") Integer num);

    List<KiteBatchAcceptDetailDTO> listExecuteDetailsOnlyNum(@Param("randomNum") String randomNum);
}
